@extends('layouts.app', ['activePage' => 'user-management', 'titlePage' => __('用户管理')])

@section('content')
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header card-header-primary">
              <h4 class="card-title ">{{ __('用户列表') }}</h4>
              <p class="card-category"> {{ __('查看用户信息\变更账号状态') }}</p>
            </div>
            <div class="card-body">
              @if (session('status'))
                <div class="row">
                  <div class="col-sm-12">
                    <div class="alert alert-success">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <i class="material-icons">close</i>
                      </button>
                      <span>{{ session('status') }}</span>
                    </div>
                  </div>
                </div>
              @endif
              <div class="table-responsive">
                <table class="table table-hover">
                  <thead class="text-primary text-center">
                  <th>
                    编号
                  </th>
                  <th>
                    用户名
                  </th>
                  <th>
                    邮箱
                  </th>
                  <th>
                    电话
                  </th>
                  <th>
                    注册时间
                  </th>
                  <th>
                    状态
                  </th>
                  <th >
                    操作
                  </th>
                  </thead>
                  <tbody>
                  @foreach($users as $user)
                    <tr class="text-center">
                      <td>
                        {{ $loop->iteration }}
                      </td>
                      <td>
                        {{ $user->username }}
                      </td>
                      <td>
                        {{ $user->email }}
                      </td>
                      <td>
                        {{ $user->phone?$user->phone:'未填写' }}
                      </td>
                      <td>
                        {{ $user->regis_time }}
                      </td>
                      <td>
                        @switch($user->status)
                        @case('0') <span class="badge badge-pill badge-success">正常</span> @break
                        @case('1') <span class="badge badge-pill badge-danger">冻结</span> @break
                        @endswitch
                      </td>
                      <td class="td-actions">
                          @if ($user->status)
                          <a href="user/{{$user->id}}" class="alert-link">启用</a>
                          @else
                          <a href="user/{{$user->id}}" class="alert-link">禁用</a>
                          @endif
                      </td>
                    </tr>
                  @endforeach
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
@endsection
